package afcp.alumni.dao.base;

import java.util.List;

import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.KeyFactory;

import afcp.alumni.model.base.MyEntity;

@Deprecated
public interface Dao<T extends MyEntity> {

	/**
	 * Returns a list of all the entities of this kind (<em>T</em>) in the
	 * datastore.
	 * 
	 * @return All the entities of kind <em>T</em> in datastore.
	 */
	public List<T> findAll();

	/**
	 * <p>
	 * Find and return the entity with the given id (the number form).
	 * </p>
	 * <p>
	 * Warning: The returned entity is detached. For instance, it can't be used
	 * to remove it from the datastore.
	 * </p>
	 * 
	 * @deprecated
	 * @param id
	 * @return
	 */
	public T find(long id);

	/**
	 * <p>
	 * Find and return the entity with the given id (the string form).
	 * </p>
	 * <p>
	 * Warning: The returned entity is detached. For instance, it can't be used
	 * to remove it from the datastore.
	 * </p>
	 * 
	 * @param id
	 * @return
	 */
	public T find(String id);

	public List<T> find(List<String> ids);

	public boolean exists(T entity);

	/**
	 * Adds the given entity to the datastore. Its Id must be set and not be
	 * already used in the datastore. If the id is already used, an error log is
	 * writen.
	 * 
	 * @param entity
	 *            The entity to add to the datastore.
	 * @return True if the entity was successfully added to the datastore, false
	 *         otherwise.
	 */
	public boolean add(T entity);

	public boolean add(List<T> entities);

	/**
	 * Removes the entity with the given id (in the string form).
	 * 
	 * @param id
	 *            The id of the entity to delete. Use the {@link KeyFactory} and
	 *            the {@link Key} objects to convert the key id from long to
	 *            {@link String}.
	 * @return
	 */
	public T remove(String id);

	public boolean remove(List<T> entities);
	
	public boolean removeAll();

	/**
	 * Updates an entity still attached to the datastore.
	 * 
	 * @param entity
	 *            The entity to update in the datastore
	 */
	public void update(T entity);

//	public List<T> search(String queryString);

}
